import pygame
from uuid import UUID

from scrape.render.node import NodeContainer, Node

class RenderManager:
    '''
    Main class for handling the rendering of a scrape graph
    '''

    def __init__(self,
            point_color: pygame.Color = (54, 69, 79), point_highlight_color: pygame.Color = (115, 147, 179),
            line_color: pygame.Color = (137, 148, 153), node_color: pygame.Color = (229, 228, 226),
            node_highlight_color: pygame.Color = (115, 147, 179), text_color: pygame.Color = (0, 0, 0),
            x_offset: int = 0, y_offset: int = 0
        ):

        self.cursor_pos: tuple[int, int] = (0, 0)

        self.point_color = point_color
        self.point_highlight_color = point_highlight_color

        self.line_color = line_color

        self.node_color = node_color
        self.node_highlight_color = node_highlight_color

        self.text_color = text_color

        self.x_offset = x_offset
        self.y_offset = y_offset

        self.nodes: NodeContainer = NodeContainer()

    def set_cursor_pos(self, x: int, y: int):
        self.cursor_pos = (x, y)

    def get_cursor_pos(self) -> tuple[int, int]:
        return self.cursor_pos

    def new_node(self, x: int, y: int) -> UUID:
        return self.nodes.new_node(x, y)

    def get_node(self, uuid: UUID) -> Node:
        return self.nodes.get_node(uuid)

    def draw(self, surface: pygame.Surface):
        self.nodes.draw(surface, self.node_color, self.node_highlight_color, self.text_color)
